package com.shijie.controller;

import com.shijie.dto.SubmitPutDTO;
import com.shijie.result.SjResult;
import com.shijie.service.SubmitService;
import com.shijie.vo.SubmitVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@RequiredArgsConstructor
public class SubmitController {

    private final SubmitService submitService;

    @PostMapping("/put")
    public SjResult<String> put(@RequestBody SubmitPutDTO submitPutDTO) {

        Long submitId = submitService.put(submitPutDTO);

        return SjResult.success(submitId.toString());
    }

    @GetMapping("/list/{userId}")
    public SjResult<List<SubmitVO>> listDefault(@PathVariable("userId") Long userId) {

        List<SubmitVO> list = submitService.listDefault(userId);

        return SjResult.success(list);
    }

    @GetMapping("/get/{submitId}")
    public SjResult<SubmitVO> get(@PathVariable("submitId") Long submitId) {

        SubmitVO submitVO = submitService.get(submitId);

        return SjResult.success(submitVO);
    }

}
